#
#  OSPFv2 test suite Makefile
#

#----------------------------------------------------------- SETUP

VERSION = 0.2.1
TOPDIR = ../../../../../../../..
include $(TOPDIR)/Makefile.common

JAVAC = javac -classpath $(SSFNET_TEST_CLASSPATH)
JAVA  = java  -classpath $(SSFNET_TEST_CLASSPATH)

# This is for the cygwin environment which has trouble with the mix of
# slashes and backslashes... Take care, that the classpath is set correctly!
ifeq ($(OSTYPE), cygwin)
JAVAC = javac
JAVA  = java
endif

SHARED=../../shared

TESTCASE=seq_num_mismatch
SIMTIME=200
DUMP_AT1=router1_2
DUMP_AT2=router2_2
DUMP_AT3=router3_2
DUMP_AT4=router4_2
DUMP_AT5=router5_2
DUMP_AT6=router6_2
DUMP_AT7=router7_2
DUMP_AT8=router8_2
REPORT=report.log

DML=$(TESTCASE).dml
LOG=$(TESTCASE).log
EVAL=$(TESTCASE).pl
TCPDUMP1=$(DUMP_AT1).tcpdump
TCPDUMP2=$(DUMP_AT2).tcpdump
TCPDUMP3=$(DUMP_AT3).tcpdump
TCPDUMP4=$(DUMP_AT4).tcpdump
TCPDUMP5=$(DUMP_AT5).tcpdump
TCPDUMP6=$(DUMP_AT6).tcpdump
TCPDUMP7=$(DUMP_AT7).tcpdump
TCPDUMP8=$(DUMP_AT8).tcpdump
DUMP1=$(DUMP_AT1).dump
DUMP2=$(DUMP_AT2).dump
DUMP3=$(DUMP_AT3).dump
DUMP4=$(DUMP_AT4).dump
DUMP5=$(DUMP_AT5).dump
DUMP6=$(DUMP_AT6).dump
DUMP7=$(DUMP_AT7).dump
DUMP8=$(DUMP_AT8).dump


#----------------------------------------------------------- MAKE test
test:
	@echo Test case $(TESTCASE).
	@echo --- Simulating scenario.
	$(JAVA) SSF.Net.Net $(SIMTIME) $(TOPDIR)/examples/net.dml $(SHARED)/testsuite.dml $(DML) > $(LOG) 2>&1
	@echo --- Converting binary tcpdump.
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP1) > $(DUMP1)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP2) > $(DUMP2)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP3) > $(DUMP3)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP4) > $(DUMP4)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP5) > $(DUMP5)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP6) > $(DUMP6)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP7) > $(DUMP7)
	$(JAVA) SSF.OS.OSPFv2.test.OSPFDumpPro $(TCPDUMP8) > $(DUMP8)
	@echo --- Evalating results.
	./$(EVAL) $(DUMP1) $(DUMP2) $(DUMP3) $(DUMP4) $(DUMP5) $(DUMP6) $(DUMP7) $(DUMP8) $(LOG) > $(REPORT)
	@cat $(REPORT)
	@echo 
	
#----------------------------------------------------------- MAKE clean
clean:
	rm -f *.log *.tcpdump *.dump *.bak